package action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.apache.struts2.ServletActionContext;

import po.User;
import service.IInfoModService;

public class InfoModAction {
	private IInfoModService infoModService;
	private User user;
	
	public String getUserInfo() {
		HttpServletRequest request = ServletActionContext.getRequest();
		HttpSession session = request.getSession();
		int userID = (int) session.getAttribute("userID");
		user = infoModService.getUser(userID);
		return "success";
	}
	
	public String modUserInfo() {
		HttpServletRequest request = ServletActionContext.getRequest();
		HttpSession session = request.getSession();
		int userID = (int) session.getAttribute("userID");
		if(infoModService.updateUser(user,userID)) {
			return "success";
		}
		return "fail";  
	}
	
	public IInfoModService getInfoModService() {
		return infoModService;
	}

	public void setInfoModService(IInfoModService infoModService) {
		this.infoModService = infoModService;
	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}
	
}
